package com.hzhr.iot.device.controller;

import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.core.annotation.Author;
import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.device.controller.base.BaseController;
import com.hzhr.iot.device.model.alarmData.AlarmDataGetModel;
import com.hzhr.iot.device.model.alarmData.AlarmDataPostModel;
import com.hzhr.iot.device.service.AlarmDataService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

@Api(tags = "AlarmData", description = "报警数据")
@RestController
@RequestMapping(value = "")
public class AlarmDataController extends BaseController {
    @Autowired
    AlarmDataService alarmDataService;

    //region /alarm-datas POST
    //region swagger响应码 : post
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : post
    @ApiOperation(value="创建报警数据", notes="创建报警数据  \n步骤 :  \n1. 如果报警数据已存在，直接返回  \n2. 新增报警数据  \n3. 向满足以下条件的用户推送报警消息  \n (1) 拥有该报警数据所对应的采集设备的数据权限  \n (2) 拥有“设备报警提醒”的角色  \n4. 返回信息  \n",produces = "application/json")
    //endregion
    //region swagger参数 : post
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })
    //endregion
    //region 请求 : post
    @RequestMapping(value = "/alarm-datas", method = RequestMethod.POST)
    //endregion
    @Author
    public ResponseEntity<AlarmDataGetModel> post(@RequestParam @ApiIgnore Map<String, Object> query,
                                                  @RequestBody AlarmDataPostModel body) throws ServiceException {
        AlarmDataGetModel responseBody = alarmDataService.post(initHeader(), query, body);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
    //region /alarm-datas GET
    //region swagger响应码 : get
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : get
    @ApiOperation(value="查询报警数据(根据报警时间降序排列)", notes="查询报警数据(根据报警时间降序排列)  \n1. 查询报警数据(根据报警时间降序排列)  \n2. 返回信息  \n",produces = "application/json")
    //endregion
    //region swagger参数 : get
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_id", value = "筛选条件 : where alarmData.id = #{equal_id}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_collectDeviceId", value = "筛选条件 : where alarmData.collectDeviceId = #{equal_collectDeviceId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_iotDeviceId", value = "筛选条件 : where alarmData.iotDeviceId = #{equal_iotDeviceId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_gasUserId", value = "筛选条件 : where alarmData.gasUserId = #{equal_gasUserId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_currentTm", value = "筛选条件 : where alarmData.currentTm = #{equal_currentTm}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "greaterthanorequal_currentTm", value = "筛选条件 : where alarmData.currentTm >= #{greaterthanorequal_currentTm}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "lessthan_currentTm", value = "筛选条件 : where alarmData.currentTm < #{lessthan_currentTm}",required = false, dataType = "long", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_id", value = "筛选条件 : where alarmData.id = #{_equal_id}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_collectDeviceId", value = "筛选条件 : where alarmData.collectDeviceId = #{_equal_collectDeviceId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_iotDeviceId", value = "筛选条件 : where alarmData.iotDeviceId = #{_equal_iotDeviceId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_gasUserId", value = "筛选条件 : where alarmData.gasUserId = #{_equal_gasUserId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_currentTm", value = "筛选条件 : where alarmData.currentTm = #{_equal_currentTm}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "_greaterthanorequal_currentTm", value = "筛选条件 : where alarmData.currentTm >= #{greaterthanorequal_currentTm}",required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "_lessthan_currentTm", value = "筛选条件 : where alarmData.currentTm < #{lessthan_currentTm}",required = false, dataType = "long", paramType = "query"),

    })
    //endregion
    //region 请求 : get
    @RequestMapping(value = "/alarm-datas", method = RequestMethod.GET)
    //endregion
    @Author
    public ResponseEntity<AlarmDataGetModel> get(@RequestParam @ApiIgnore Map<String, Object> query) throws ServiceException {
        AlarmDataGetModel responseBody = alarmDataService.get(initHeader(), query);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
}









































































































































































































































































































































































































































































































































































































































